﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="fixedPriceOrderEdit.aspx.cs"
    Inherits="PeisongWeb.admin.fixedPriceOrderEdit" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Register TagName="top" Src="controls/top.ascx" TagPrefix="uc1" %>
<%@ Register TagName="menu" Src="controls/menu.ascx" TagPrefix="uc2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>添加补单 - 想购网长期采购物流配送系统</title>
    <!--#include file="style.inc"-->

    <script type="text/javascript" language="javascript" src="../app_common/scripts/jquery-cn.js"></script>

    <script type="text/javascript">
        
        
        function chkFm() {
            var patrn = /^[\-\+]?([0-9]\d*|0|[1-9]\d{0,2}(,\d{3})*)(\.\d+)?$/;
            if ($("#drp_company").val() == "") {
                $("#val_company").show();
                return false;
            }
            if ($("#txt_taxfee").val() == "") {
                $("#val_taxfee").show();
                return false;
            }

            if (!patrn.exec($("#txt_taxfee").val())) {
                $("#val_taxfee").html("格式不正确！");
                $("#val_taxfee").show();
                return false;
            }

            if ($("#txt_fireightFee").val() == "") {
                $("#val_fireightFee").show();
                return false;
            }

            if (!patrn.exec($("#txt_fireightFee").val())) {
                $("#val_fireightFee").html("格式不正确！");
                $("#val_fireightFee").show();
                return false;
            }
            if ($("#hd_proScope").val() == "") {
                $("#val_proScope").show();
                return false;
            }

            if ($("#txt_Amount").val() == "") {
                $("#val_Amount").show();
                return false;
            }
            if (!patrn.exec($("#txt_Amount").val())) {
                $("#val_Amount").html("格式不正确！");
                $("#val_Amount").show();
                return false;
            }
            return true;
        }

        function chkCompany() {
            if ($("#drp_company").val() == "") {
                $("#val_company").show();
                return false;
            }
            if ($("#txt_taxfee").val() == "") {
                $("#val_taxfee").show();
                return false;
            }
            if ($("#txt_fireightFee").val() == "") {
                $("#val_fireightFee").show();
                return false;
            }
            return true;
        }

        function checkCountNum(obj) {
            if (obj.value != "" && obj.value != "0") {
                var flag = IsPriceNumeric(obj.value);
                if (!flag)
                    obj.value = "1";
            }
            else
                obj.value = "1";
        }

        function checkCountNum2(obj) {
            if (obj.value != "" && obj.value != "0") {
                var flag = IsPriceNumeric2(obj.value);
                if (!flag)
                    obj.value = "1";
            }
            else
                obj.value = "1";
        }
        
        function IsPriceNumeric(oNum) {
            var strP = /^\d+(\.\d)?$/;
            if (strP.test(oNum))
                return true;
            else
                return false;
        }
        function IsPriceNumeric2(oNum) {
            var strP = /^\d+(\.\d\d)?$/;
            if (strP.test(oNum))
                return true;
            else
                return false;
        }
        
        

        function resetSrh() {
            document.getElementById("txt_ProductNo").value = "";
            document.getElementById("txt_ProductName").value = "";
        }

        function selectAll(obj) {
            if ($(obj).attr("checked") == true) { // 全选 
                $(":checkbox").each(function() { //可以对.net服务器控件有效 
                    $(this).attr("checked", true);
                });
            } else { // 取消全选 
                $(":checkbox").each(function() { //可以对.net服务器控件有效
                    $(this).attr("checked", false);
                });
            }
        }
        function checkSelect() {
            var cbo = 0;
            $(":checkbox").each(function(i, n) {
                if (this.checked) {
                    // price = $("#txt_price_" + proId).val();
                    cbo++;
                }
            });
            if (cbo == 0) {
                alert("请选择商品！");
                return false;
            }
            else
                return true;
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="sm1" runat="server">
    </asp:ScriptManager>
    <ext:ScriptManager ID="ScriptManager1" runat="server" />
    <uc1:top ID="Top1" runat="server" />
    <uc2:menu ID="Menu1" runat="server" />
    <div id="admin_main" style="margin: 10px 0 0 10px;">
        <ext:Panel ID="Panel2" runat="server" Title="添加补单" BodyStyle="padding:5px 5px 0"
            Width="650" Frame="true" ButtonAlign="Center">
            <Body>
                <ext:Panel ID="Panel3" runat="server">
                    <Body>
                        <ext:ColumnLayout ID="ColumnLayout1" runat="server">
                            <ext:LayoutColumn ColumnWidth=".5">
                                <ext:Panel ID="Panel4" runat="server" Border="false" Header="false">
                                    <Body>
                                        <asp:UpdatePanel runat="server" ID="UpdatePanel2" UpdateMode="Conditional">
                                            <Triggers>
                                                <asp:PostBackTrigger ControlID="btn_Save" />
                                                <asp:PostBackTrigger ControlID="lbn_AddProduct" />
                                            </Triggers>
                                            <ContentTemplate>
                                                <div id="admin_edit_content">
                                                    <ul>
                                                        <li>
                                                            <label>
                                                                公司名称：</label>
                                                            <asp:DropDownList runat="server" ID="drp_company" DataTextField="company" DataValueField="companyId"
                                                                AutoPostBack="true" OnSelectedIndexChanged="drp_company_SelectedIndexChanged">
                                                            </asp:DropDownList>
                                                            <span id="val_company" style="color: Red; display: none">请选择公司名称</span> </li>
                                                        <li>
                                                            <label>
                                                                联系人姓名：</label>
                                                            <asp:Label runat="server" ID="lbl_contact"></asp:Label>
                                                        </li>
                                                        <li>
                                                            <label>
                                                                联系方式：</label>
                                                            <asp:Label runat="server" ID="lbl_contactMobile"></asp:Label>
                                                            <asp:Label runat="server" ID="lbl_contactPhone"></asp:Label>
                                                        </li>
                                                        <li>
                                                            <label>
                                                                收货地址：</label>
                                                            <asp:Label runat="server" ID="lbl_Address"></asp:Label>
                                                        </li>
                                                        <li>
                                                            <label>
                                                                税 费：</label>
                                                            <input runat="server" id="txt_taxfee" name="" type="text" value="0.00" />
                                                            <span id="val_taxfee" style="color: Red; display: none">请输入税费，如果没有税费为：0.00</span>
                                                        </li>
                                                        <li>
                                                            <label>
                                                                运费：</label>
                                                            <input runat="server" id="txt_fireightFee" name="" type="text" value="0.00" />
                                                            <span id="val_fireightFee" style="color: Red; display: none">请输入税费，如果没有运费为：0.00</span>
                                                        </li>
                                                    </ul>
                                                    <p>
                                                        &nbsp;</p>
                                                    <table width="98%" border="0" cellpadding="4" cellspacing="1">
                                                        <tr>
                                                            <td>
                                                                <h2 style="float: left; margin-right: 20px">
                                                                    商品信息
                                                                </h2>
                                                                <asp:LinkButton runat="server" ID="lbn_AddProduct" Text="添加商品" OnClick="lbn_AddProduct_Click"
                                                                    OnClientClick="return chkCompany()"></asp:LinkButton>
                                                                <%-- <a style="color: #0000FF; cursor: pointer" onclick="showSearch();">添加商品</a> --%>
                                                                <span id="val_proScope" style="color: Red; display: none; margin-left: 20px">未选择商品，不能提交订单，请选择商品！</span>
                                                                <hr />
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <div id="admin_edit_content_infor" style="width: 630px">
                                                                    <span id="span_selectPros">
                                                                        <table width="98%">
                                                                            <tr align="center" style="height: 20px;">
                                                                                <td width="5%" bgcolor="#C0D5F0">
                                                                                    序号
                                                                                </td>
                                                                                <td width="25%" bgcolor="#C0D5F0">
                                                                                    商品名称
                                                                                </td>
                                                                                <td width="10%" bgcolor="#C0D5F0">
                                                                                    供应价
                                                                                </td>
                                                                                <td width="10%" bgcolor="#C0D5F0">
                                                                                    商品价格
                                                                                </td>
                                                                                <td width="5%" bgcolor="#C0D5F0">
                                                                                    商品数量
                                                                                </td>
                                                                                <td width="30%" bgcolor="#C0D5F0">
                                                                                    备注信息
                                                                                </td>
                                                                                <td width="8%" bgcolor="#C0D5F0">
                                                                                    合计
                                                                                </td>
                                                                                <td width="15%" bgcolor="#C0D5F0">
                                                                                    删除
                                                                                </td>
                                                                            </tr>
                                                                            <asp:Repeater runat="server" ID="rpt_pro" OnItemCommand="rpt_pro_ItemCommand">
                                                                                <ItemTemplate>
                                                                                    <tr align="center" style="height: 20px;">
                                                                                        <td bgcolor="#FFFFFF">
                                                                                            <%#Eval("number")%>
                                                                                        </td>
                                                                                        <td bgcolor="#FFFFFF">
                                                                                            <a target="_blank" href="../user_productDetail_<%#Eval("proId")%>.html">
                                                                                                <%#Eval("proName")%>
                                                                                            </a>
                                                                                        </td>
                                                                                        <td bgcolor="#FFFFFF">
                                                                                            ￥<span class="red"><%#Eval("sellerPrice")%></span>
                                                                                        </td>
                                                                                        <td bgcolor="#FFFFFF">
                                                                                            ￥<span class="red"><%#Eval("price")%></span>
                                                                                        </td>
                                                                                        <td bgcolor="#FFFFFF">
                                                                                            <label id='lbl_quantity<%#Eval("proId") %>'>
                                                                                                <%#Eval("quantity")%></label>
                                                                                        </td>
                                                                                        <td bgcolor="#FFFFFF">
                                                                                            <%#Eval("note")%>
                                                                                        </td>
                                                                                        <td bgcolor="#FFFFFF">
                                                                                            <%#Eval("amount") %>
                                                                                        </td>
                                                                                        <td bgcolor="#FFFFFF">
                                                                                            <%--  <a href="javascript:delSelectPro('<%#Eval("proId")%>')">删除</a>--%>
                                                                                            <asp:LinkButton ID="lbn_Del" runat="server" CommandName="DEL" CommandArgument='<%# Eval("proId") %>'
                                                                                                Text="删除">
                                                                                            </asp:LinkButton>
                                                                                        </td>
                                                                                    </tr>
                                                                                </ItemTemplate>
                                                                            </asp:Repeater>
                                                                            <tr align="center" style="height: 20px;">
                                                                                <td bgcolor="#C0D5F0" colspan="6">
                                                                                    合&nbsp;&nbsp;计
                                                                                </td>
                                                                                <td bgcolor="#FFFFFF" align="right">
                                                                                    ￥<span class="red" runat="server" id="span_proSum"></span>
                                                                                </td>
                                                                            </tr>
                                                                        </table>
                                                                    </span><span style="margin-left: 150px; margin-top: 10px">
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    <p>
                                                        &nbsp;</p>
                                                    <ul>
                                                        <li>
                                                            <label>
                                                                订单总价：</label>
                                                            <asp:Label runat="server" ID="lbl_StandardAmount"></asp:Label>
                                                        </li>
                                                        <li>
                                                            <label>
                                                                支付总价：</label>
                                                            <input runat="server" id="txt_Amount" name="" type="text" readonly="readonly" style="background-color: #f0f0f0" />
                                                            <span id="val_Amount" style="color: Red; display: none">请填写支付总价</span> </li>
                                                        <li>
                                                            <label>
                                                                收货时间：</label>
                                                            <span style="float: left">
                                                                <%-- <ext:DateField ID="ext_receiveDt" runat="server" AllowBlank="true" ReadOnly="true" />--%>
                                                                <%=DateTime.Now.AddDays(1).ToShortDateString() %>
                                                            </span>
                                                            <asp:DropDownList runat="server" ID="ddl_receiveTime">
                                                                <asp:ListItem Value="7">7:00</asp:ListItem>
                                                                <asp:ListItem Value="8">8:00</asp:ListItem>
                                                                <asp:ListItem Value="9">9:00</asp:ListItem>
                                                                <asp:ListItem Value="10">10:00</asp:ListItem>
                                                                <asp:ListItem Value="11">11:00</asp:ListItem>
                                                                <asp:ListItem Value="12">12:00</asp:ListItem>
                                                                <asp:ListItem Value="13">13:00</asp:ListItem>
                                                                <asp:ListItem Value="14">14:00</asp:ListItem>
                                                                <asp:ListItem Value="15">15:00</asp:ListItem>
                                                                <asp:ListItem Value="16">16:00</asp:ListItem>
                                                                <asp:ListItem Value="17">17:00</asp:ListItem>
                                                                <asp:ListItem Value="18">18:00</asp:ListItem>
                                                                <asp:ListItem Value="19">19:00</asp:ListItem>
                                                            </asp:DropDownList>
                                                        </li>
                                                        <li>
                                                            <label>
                                                                客户备注：</label>
                                                            <asp:TextBox runat="server" ID="txt_Note" Rows="3" Columns="20" TextMode="MultiLine"
                                                                Text="此订单为补单，商品已发货" MaxLength="500"></asp:TextBox>
                                                        </li>
                                                        <li>
                                                            <label>
                                                                &nbsp;</label>
                                                            <asp:Button runat="server" ID="btn_Save" Text="保　存" OnClick="btn_Save_Click" OnClientClick="return chkFm()" />
                                                            <input type="button" id="btn_Return" value="返　回" onclick="window.location.href='orderList.aspx'" />
                                                            <input id="hd_proScope" runat="server" value="" type="hidden" />
                                                            <input id="hd_TotalAmount" runat="server" value="0.00" type="hidden" />
                                                        </li>
                                                    </ul>
                                                </div>
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                    </Body>
                                </ext:Panel>
                            </ext:LayoutColumn>
                        </ext:ColumnLayout>
                    </Body>
                </ext:Panel>
            </Body>
        </ext:Panel>
        <ext:Window ID="win_product" runat="server" Title="添加商品" Height="550px" Width="900px"
            BodyStyle="padding: 6px; background-color: #fff;" AutoScroll="true" Modal="True"
            Resizable="false" ShowOnLoad="false" Draggable="false" Icon="ApplicationViewDetail">
            <Body>
                <asp:UpdatePanel runat="server" ID="up1" UpdateMode="Conditional">
                    <Triggers>
                        <asp:PostBackTrigger ControlID="lbn_AddOrderItem" />
                    </Triggers>
                    <ContentTemplate>
                        <div class="details">
                            <table width="98%" border="0" cellpadding="4" cellspacing="1" style="text-align: left">
                                <tr>
                                    <td style="width: 18%">
                                        <label>
                                            大 类：</label>
                                        <asp:DropDownList runat="server" ID="ddl_CategoryRoot" DataTextField="name" DataValueField="categoryId"
                                            AutoPostBack="True" OnSelectedIndexChanged="ddl_CategoryRoot_SelectedIndexChanged">
                                        </asp:DropDownList>
                                    </td>
                                    <td style="width: 18%">
                                        <label>
                                            小 类：</label>
                                        <asp:DropDownList runat="server" ID="ddl_CategorySub" DataTextField="name" DataValueField="categoryId">
                                        </asp:DropDownList>
                                    </td>
                                    <td style="width: 18%">
                                        商品编号:<asp:TextBox ID="txt_ProductNo" runat="server" Width="80px"></asp:TextBox>
                                    </td>
                                    <td style="width: 18%">
                                        商品名称:<asp:TextBox ID="txt_ProductName" runat="server" Width="80px"></asp:TextBox>
                                    </td>
                                    <td style="width: 16%">
                                        <asp:LinkButton ID="lbn_search" runat="server" Text="［搜索］" CausesValidation="false"
                                            OnClick="lbn_search_Click">
                                        </asp:LinkButton>
                                        <a href="javascript:resetSrh();">［重置］</a>
                                    </td>
                                    <td style="width: 16%">
                                        <asp:LinkButton ID="lbn_AddOrderItem" runat="server" Text="［添加到订单］" OnClientClick="return checkSelect()"
                                            CausesValidation="false" OnClick="lbn_AddOrderItem_Click">
                                        </asp:LinkButton>
                                    </td>
                                </tr>
                            </table>
                            <table id="tb_pro" width="98%" border="0" cellpadding="4" cellspacing="1" bgcolor="#99BBE8"
                                style="text-align: left">
                                <tr align="center" style="height: 20px;">
                                    <td width="6%" bgcolor="#C0D5F0">
                                        商品编号
                                    </td>
                                    <td width="25%" bgcolor="#C0D5F0">
                                        商品名称
                                    </td>
                                    <td width="15%" bgcolor="#C0D5F0">
                                        供应价
                                    </td>
                                    <td width="15%" bgcolor="#C0D5F0">
                                        购买价
                                    </td>
                                    <td width="10%" bgcolor="#C0D5F0">
                                        数量
                                    </td>
                                    <td width="23%" bgcolor="#C0D5F0">
                                        添加备注
                                    </td>
                                    <td width="12%" bgcolor="#C0D5F0">
                                        <input type="checkbox" name="”checkedAll”" id="checkedAll" onclick="selectAll(this)" />全选
                                    </td>
                                </tr>
                                <asp:Repeater runat="server" ID="rpt_Products">
                                    <ItemTemplate>
                                        <tr align="center" style="height: 20px;">
                                            <td bgcolor="#FFFFFF">
                                                <%# Eval("productNo")%>
                                                <asp:HiddenField ID="hid_productId" runat="server" Value='<%#Eval("productId") %>' />
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <a target="_blank" href="../user_productDetail_<%#Eval("productId")%>.html">
                                                    <asp:Label runat="server" ID="lbl_proName" Text='<%# Eval("Name")%>'></asp:Label>
                                                </a>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                ￥<asp:Label runat="server" ID="lbl_SellerPrice" Text='<%#string.Format("{0:F2}", Eval("sellerPrice"))%>'></asp:Label>
                                                元/<asp:Label runat="server" ID="lbl_unit" Text='<%#Eval("unit")%>'></asp:Label>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                ￥<asp:TextBox ID="txt_BuyPrice" onblur='checkCountNum2(this);' onafterpaste='checkCountNum2(this);'
                                                    Text="1" runat="server" Width="60px"></asp:TextBox>
                                                元/<asp:Label runat="server" ID="Label1" Text='<%#Eval("unit")%>'></asp:Label>
                                            </td>
                                            <td bgcolor="#FFFFFF" align="center">
                                                <asp:TextBox ID="txtQuantity" onblur='checkCountNum(this);' onafterpaste='checkCountNum(this);'
                                                    runat="server" Text="1" MaxLength="8" Width="60px"></asp:TextBox>
                                            </td>
                                            <td bgcolor="#FFFFFF" align="center">
                                                <asp:TextBox ID="txtNote" runat="server" Width="150px" MaxLength="200"></asp:TextBox>
                                            </td>
                                            <td bgcolor="#FFFFFF" align="center">
                                                <asp:CheckBox ID="cbx_isSelect" runat="server" />
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </table>
                            <div>
                                <webdiyer:AspNetPager ID="AspNetPager2" NumericButtonType="Text" MoreButtonType="Text"
                                    runat="server" AlwaysShow="False" PageSize="20" InvalidPageIndexErrorMessage="无效页码"
                                    PageIndexOutOfRangeErrorMessage="页码超出范围" ShowCustomInfoSection="Left" CustomInfoHTML=" 每页%PageSize%条记录 | 总共%RecordCount%条记录 "
                                    CustomInfoTextAlign="Left" HorizontalAlign="Right" OnPageChanged="AspNetPager2_PageChanged"
                                    NextPageText="下一页" FirstPageText="首页" LastPageText="末页" PrevPageText="上一页">
                                </webdiyer:AspNetPager>
                            </div>
                            <span runat="server" id="lbl_msg" style="padding-top: 20px; color: Red">对不起，该采购商没有添加采购范围！</span>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </Body>
        </ext:Window>
    </div>
    </form>
</body>
</html>
